<?php
session_start();

// 假设用户名和密码存储在一个数组或数据库中
$users = [
    'admin' => 'admin', // 示例用户数据
];

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];


    // 验证用户信息
    if (isset($users[$username]) && $users[$username] === $password) {
        $_SESSION['username'] = $username;
        $_SESSION['uid'] = '1';
        header('Location: index.php'); // 登录成功后重定向回首页
        exit();
    } else {
        echo "用户名或密码错误";
    }
}
?>
